package com.dlc.felear.xiaoensale.message;

import android.util.Log;

import com.dlc.felear.xiaoensale.helper.JsonHelper;
import com.dlc.felear.xiaoensale.utils.DesUtils;

/**
 * Author：Mapogo
 * Date：2021/1/13
 * Note：
 */
public class AbsMessage implements IMessage {
    private static final String KEY = "DLCappis";
    public AbsMessage() {
    }

    @Override
    public byte[] pack() {
        try {
            String content=JsonHelper.toJson(this);
            Log.e("AbsMessage","加密前的数据："+content);
            String strData = DesUtils.encode(KEY, content);
            String strLen = Integer.toHexString(strData.length());
            while (strLen.length() < 4) {
                strLen = '0' + strLen;
            }
            String resultContent = "DLC" + strLen + strData;
            return resultContent.getBytes();
        }catch (Exception e){

        }
        return null;
    }
}
